#include <iostream>

using namespace std;

class A
{
private:
        int i;
        int *p;
public:
    A() :p(0){cout<<"A::A()"<<endl;}
    ~A() {if(p) delete p; cout<<"A::~A()"<<i<<endl;}
    void set(int ii) {i=ii;}
    void f(){ p=new int;}
    void g(A* q){cout<<"A::g(),q->i="<<q->i<<endl;}
};

int main()
{
    A* P=new A[10];
    for(int i=0;i<10;i++)
        P[i].set(i);

    A b;
    b.set(100);
    P[0].g(&b);
    delete [] P;

    int i;
    cin>>i;
    return 0;
}